//********************************************************************************************************
// Product Name: MapWindow.dll Alpha
// Description:  The basic module for MapWindow version 6.0
//********************************************************************************************************
// The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); 
// you may not use this file except in compliance with the License. You may obtain a copy of the License at 
// http://www.mozilla.org/MPL/ 
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 
// ANY KIND, either expressed or implied. See the License for the specificlanguage governing rights and 
// limitations under the License. 
//
// The Original Code is from MapWindow.dll version 6.0
//
// The Initial Developer of this Original Code is Ted Dunsford. Created 6/19/2008 2:45:32 PM
// 
// Contributor(s): (Open source contributors should list themselves and their modifications here). 
//
//********************************************************************************************************

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.ComponentModel;

using Microsoft.DirectX;

namespace MapWindow.DirectX
{


    /// <summary>
    /// ModelSymbolizer symbolizes the lighting, scale, rotation for the models on a layer
    /// </summary>
    public class ModelSymbolizer : Component
    {
        #region Private Variables

        float _scale;
       
        EditVector _translation;
        EditVector _rotation;
        private MapWindow.Drawing.ScaleModes _scaleMode;
        #endregion

        #region Constructors

        /// <summary>
        /// Creates a new instance of ModelSymbolizer
        /// </summary>
        public ModelSymbolizer()
        {
            _scale = 1;
            _scaleMode = MapWindow.Drawing.ScaleModes.Geographic;
            _translation = new EditVector();
            _rotation = new EditVector();
        }

        #endregion

        #region Methods

        /// <summary>
        /// Returns a new transformation matrix with the scale, yaw, pitch and roll factored in
        /// </summary>
        /// <returns>A Transformation Matrix</returns>
        public virtual Matrix GetMatrix()
        {
            
            Matrix result = Matrix.Scaling(_scale, _scale, _scale);
           
            result = Matrix.Multiply(result, Matrix.RotationX(Convert.ToSingle(_rotation.X * Math.PI/180)));
            result = Matrix.Multiply(result, Matrix.RotationY(Convert.ToSingle(_rotation.Y * Math.PI / 180)));
            result = Matrix.Multiply(result, Matrix.RotationZ(Convert.ToSingle(_rotation.Z * Math.PI / 180)));
            //result = Matrix.Multiply(result, Matrix.RotationYawPitchRoll(Convert.ToSingle(_yaw * Math.PI / 180), Convert.ToSingle( _pitch * Math.PI / 180),Convert.ToSingle( _roll * Math.PI / 180)));
            result = Matrix.Multiply(result, Matrix.Translation(_translation.Vector));
            return result;
        }


        #endregion

        #region Properties

        /// <summary>
        /// Scale
        /// </summary>
        [Category("Transform"),Description("A multiplier from the original model scale units")]
        public float Scale
        {
            get { return _scale; }
            set { _scale = value; }

        }

       

        /// <summary>
        /// Gets or sets a layer-wide adjustment to elevation
        /// </summary>
        [Category("Transform"), Description("Specifies a world-coordinate translation to apply to the entire layer")]
        public EditVector Translation
        {
            get { return _translation; }
            set { _translation = value; }
        }


        /// <summary>
        /// Gets or sets a layer-wide adjustment to elevation
        /// </summary>
        [Category("Transform"), Description("Specifies a world-coordinate translation to apply to the entire layer")]
        public EditVector Rotation
        {
            get { return _rotation; }
            set { _rotation = value; }
        }

        /// <summary>
        /// Gets or sets the scaling mode for this layer
        /// </summary>
        public MapWindow.Drawing.ScaleModes ScaleMode
        {
            get { return _scaleMode; }
            set { _scaleMode = value; }
        }


        #endregion



    }
}
